<?php
/*
 * @Author: your name
 * @Date: 2020-01-08 14:56:52
 * @LastEditTime : 2020-01-08 17:38:30
 * @LastEditors  : Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /php/application/common/service/NetfilterVirtualRuleHitLog.php
 */

namespace app\common\service;


class NetfilterVirtualRuleHitLog extends Base 

{
    /**
     * @name: 列表
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2020-01-08 14:58:15
     */
    function list ($filterData, $limit)
    {

        $db = db('NetfilterVirtualRuleHitLog')->where('host_id', $filterData['host_id']);
        !isset($filterData['rule_name']) || empty($filterData['rule_name']) ? : $db->whereLike('rule_name', '%' . $filterData['rule_name'] . '%');
        !isset($filterData['src_ip']) || empty($filterData['src_ip']) ? : $db->whereLike('src_ip', '%' . $filterData['src_ip'] . '%');
        !isset($filterData['dest_ip']) || empty($filterData['dest_ip']) ? : $db->whereLike('dest_ip', '%' . $filterData['dest_ip'] . '%');
        !isset($filterData['dest_port']) || empty($filterData['dest_port']) ? : $db->whereLike('dest_port', '%' . $filterData['dest_port'] . '%');
        !isset($filterData['direction']) || !is_numeric($filterData['direction']) ? : $db->where('direction', $filterData['direction']);
        $return = $db->paginate($limit)->toArray();

        return $return;
    }

    /**
     * @name: 添加
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2020-01-08 15:03:54
     */
    function batchAdd ($data)
    {
        db('NetfilterVirtualRuleHitLog')->insertAll($data);
    }
}